#pragma once

#include "HashTable.h"

template<class K, class KeyToInt = keyToIntFunc<K>>
class UnorderedSet
{
public:
	struct setKeyOfT
	{
		const K& operator()(const K& key)
		{
			return key;
		}
	};
	typedef typename HashBucket::HashTable<K, K, setKeyOfT, KeyToInt>::const_iterator iterator;
	typedef typename HashBucket::HashTable<K, K, setKeyOfT, KeyToInt>::const_iterator const_iterator;


	iterator begin()
	{
		return _ht.begin();
	}

	iterator end()
	{
		return _ht.end();
	}

	const_iterator begin()const
	{
		return _ht.begin();
	}

	const_iterator end()const
	{
		return _ht.end();
	}

	pair<iterator,bool> insert(const K& key)
	{
		return _ht.Insert(key);
	}

	iterator find()
	{
		return _ht.Find();
	}
	bool erase()
	{
		return _ht.Erase();
	}

private:
	HashBucket::HashTable<K, K, setKeyOfT, KeyToInt> _ht;
};

void UnorderedSet_test1()
{
	int arr[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15,106 };
	UnorderedSet<int> m;
	m.insert(1);
	m.insert(7);
	m.insert(5);
	m.insert(2);
	m.insert(8);
	for (auto e : arr)
	{
		m.insert(e);
	}

	UnorderedSet<int>::iterator it = m.begin();
	while (it != m.end())
	{
		//(*it)++;
		cout << *it << " ";
		++it;
	}
	cout << endl;
	for (auto e : m)
	{
		cout << e << " ";
	}
	cout << endl;

}